/*
 * @Author: mikey.zhaopeng 
 * @Date: 2018-12-17 21:06:11 
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2018-12-17 22:48:09
 */
import 'package:flutter/material.dart';
import '../common/utils.dart' show Utils;
import '../modles//lib_resource.dart' show LibResource;
import '../widgets/tag.dart' show Tag;

class VideoListTail extends StatelessWidget {
  final Map resource;

  VideoListTail({Key key, this.resource}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    LibResource res = LibResource.fromJson(resource);
    String date = '';
    int timestap = int.tryParse(res.itemupdate);
    date = timestap == null ? res.itemupdate : Utils.readTimeStap(timestap);
    return Container(
      margin: const EdgeInsets.all(8.0),
      child: Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Hero(
                tag: res.poster ?? res.cnname,
                child: Container(
                  height: 100.0,
                  width: 100.0,
                  child: Container(
                    decoration: BoxDecoration(
                        image: DecorationImage(
                            fit: BoxFit.contain,
                            image: res.posterM == null
                                ? AssetImage("assets/images/placeholder.png")
                                : NetworkImage(res.posterM))),
                  ),
                ),
              ),
              SizedBox(
                width: 8.0,
              ),
              Expanded(
                child: Container(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.symmetric(vertical: 4.0),
                        child: Text(
                          res.cnname,
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(fontSize: 16.0),
                          ),
                      ),
                      res.area.isNotEmpty
                      ?Tag(
                        text: res.area,
                        color: Theme.of(context).primaryColor,
                        border: true,
                      ):Container(),
                      SizedBox(height: 8.0,),
                      Text(
                        res.category,
                        style: Theme.of(context).textTheme.body2,
                      ),
                      Text(
                        res.playStatus,
                        style: Theme.of(context).textTheme.body2,
                      ),
                      Text(
                        date,
                        style: Theme.of(context).textTheme.body2,
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                      )
                    ],
                  ),
                ),
              ),
              Card(
                elevation: 2.0,
                child: Container(
                  width: 60.0,
                  height: 60.0,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text("Score"),
                      Text(
                        res.score,
                        style:TextStyle(fontSize:24.0),
                      )
                    ],
                  ),
                ),
              )
            ],
          ),
        ],
      ),
    );
  }
}
